<?php

namespace App\Http\Controllers\Home;

use App\Handlers\ImageUploadHandler;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class CommonController extends Controller
{
    public function download()
    {
        return view('home.download');
    }

    public function wang_upload(Request $request, ImageUploadHandler $uploader)
    {

        if ($request->hasFile('wangEditorH5File') && $request->file('wangEditorH5File')->isValid()) {
            $file = $request->File('wangEditorH5File');
            $res = $uploader->save($file, 'common', 2);
            $save[] = config('app.img_url') . $res['path'];
            return response()->json(['errno' => 0, 'data' => $save]);
        } else {
            return response()->json(['errno' => 0, 'data' => $res, 'info' => 'no picture']);
        }

    }

    public function customer(Request $request)
    {
        $user = $request->user;

        dd($user);
        
        return view('home.customer');
    }

}
